'''
Descripttion: 
Author: equipment copyWhite
Date: 2024-12-30 11:38:12
LastEditTime: 2024-12-30 12:22:19
'''
from db import db

# 维修表
class Service(db.Model):
    __tablename__ = 'tb_service'
    service_id = db.Column(db.String(255), primary_key=True)
    equipment_id = db.Column(db.String(255), db.ForeignKey('tb_equipment.equipment_id'), nullable=False)
    sequence_id = db.Column(db.String(255), db.ForeignKey('tb_equipment_fault.sequence_id'), nullable=False)
    maintenance_date = db.Column(db.String(255))
    maintenance_content = db.Column(db.String(255))
    change_configuration = db.Column(db.String(255))
    maintenance_count = db.Column(db.String(255))
    maintenance_person = db.Column(db.String(255))
    remark = db.Column(db.String(255))    


    def __init__(self, service_id, equipment_id, sequence_id, maintenance_date, maintenance_content, change_configuration,maintenance_count, maintenance_person, remark):
        self.service_id = service_id
        self.equipment_id = equipment_id
        self.sequence_id = sequence_id
        self.maintenance_date = maintenance_date
        self.maintenance_content = maintenance_content
        self.change_configuration = change_configuration
        self.maintenance_count = maintenance_count
        self.maintenance_person = maintenance_person
        self.remark = remark

    def get(self):
        return {
            "service_id": self.service_id,
            "equipment_id": self.equipment_id,
            "sequence_id": self.sequence_id,
            "maintenance_date": self.maintenance_date,
            "maintenance_content": self.maintenance_content,
            "change_configuration": self.change_configuration,
            "maintenance_count": self.maintenance_count,
            "maintenance_person": self.maintenance_person,
            "remark": self.remark            
        }
        

    def __repr__(self):
        return f'<Service {self.service_id}>'